import * as apiService from '@/services/api';

/**
 * 资金调整配置
 * @param params
 * @returns {Promise<*>}
 *
 */
const updateAdjustmentConfigs = params => apiService.post(api.ADJUSTMENT_CONFIGS, params);
/**
 * 资金调整用户校验
 * @param params
 * @returns {Promise<*>}
 *
 */
const validateAdjustmentUsers = ({
  users,
} = {}) => apiService.post(api.ADJUSTMENT_USERS_VALIDATE, {
  users,
});
/**
 * 获取资金审核列表
 * @param params
 * @returns {Promise<*>}
 *
 */
const getAdjustmentList = params => apiService.post(api.ADJUSTMENT_LIST, params);
/**
 * 获取申请人列表
 * @param params
 * @returns {Promise<*>}
 *
 */
const getCreatorList = params => apiService.post(api.ADJUSTMENT_CREATOR_LIST, params);
/**
 * 获取一审人列表
 * @param params
 * @returns {Promise<*>}
 *
 */
const getFirstApproverList = params => apiService.post(api.ADJUSTMENT_FIRST_APPROVER_LIST, params);
/**
 * 获取二审人列表
 * @param params
 * @returns {Promise<*>}
 *
 */
const getSecondApproverList = params => apiService.post(api.ADJUSTMENT_SECOND_APPROVER_LIST, params);
/**
 * 获取会员审核记录详情
 * @param params
 * @returns {Promise<*>}
 *
 */
const getAdjustmentDetail = params => apiService.post(api.ADJUSTMENT_DETAIL, params);
/**
 * 提交审核内容
 * @param id
 * @param step  1/2 一审/二审
 * @param comment 备注
 * @param status 审核结果
 * @returns {Promise<*>}
 *
 */
const updateAdjustment = ({
  orderId, step, remark, status, menuId,
}) => {
  if (step === 1) {
    return apiService.post(api.ADJUSTMENT_FIRST_APPROVER_STATUS, {
      orderId, step, remark, status, menuId,
    });
  }
  return apiService.post(api.ADJUSTMENT_SECOND_APPROVER_STATUS, {
    orderId, step, remark, status, menuId,
  });
};

/**
 * 导出资金调整审核记录
 * @param params
 * @returns {Promise<*>}
 *
 */
const exportAduitLogs = params => apiService.post(api.EXPORT_ADUIT_LOGS, params);

export {
  getAdjustmentList,
  validateAdjustmentUsers,
  getAdjustmentDetail,
  updateAdjustmentConfigs,
  updateAdjustment,
  getCreatorList,
  getFirstApproverList,
  getSecondApproverList,
  exportAduitLogs,
};
